<template>
    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item :to="{ path: '/' }"><i class="el-icon-lx-cascades"></i> 首页</el-breadcrumb-item>
                <el-breadcrumb-item> 信息发布</el-breadcrumb-item>
                <el-breadcrumb-item :to="{ path: '/details' }">信息详情</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="shell">
            <el-row class="back">
                <el-button type="primary" @click="goMessage">返回</el-button>
            </el-row>
            <div class="count">
                <el-input class="headline" placeholder="请输入内容" v-model="formObj.title">
                    <template slot="prepend">标题</template>
                </el-input>
                <el-input class="headline" placeholder="请输入内容" v-model="formObj.content">
                    <template slot="prepend">内容</template>
                </el-input>
                <div class="imgBox" style="margin-top: 20px;">
                    <img v-for="item in imgList" :src="item" alt="" style="width: 150px;height: 150px; margin-right: 10px;">
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import { Getselectnotices } from '@/api/messagePublish'
export default {
    data() {
        return {
            formObj: {},
            imgList: []
        }
    },
    mounted() {
        this.getData()
    },
    methods: {
        //获取表单数据
        async getData() {
            let parmas = {
                id: this.$route.query.id
            }
            let result = await Getselectnotices(parmas)
            //发送成功时做的操作
            if (result.code == 200) {
                this.formObj = result.data.list[0]
                this.imgList = result.data.list[0].img.split(',').map(item => 'http://www.img.ttblog.cn/' + item);
            }
        },
        //返回
        goMessage() {
            if (this.$route.query.from) {
                this.$router.push(this.$route.query.from)
                return
            } else {
                this.$router.push('/notice')
            }

        }
    },

}
</script>

<style scoped>
.shell {
    width: 98%;
    height: 90%;
    margin: auto;
    margin-top: 10px;
    background-color: #FFFFFF;
}

.el-select .el-input {
    width: 130px;
}

.input-with-select .el-input-group__prepend {
    background-color: #fff;
}

.count {
    width: 90%;
    margin: auto;
    padding-top: 50px;
}

.headline {
    height: 30px;
}

.back {
    position: relative;
    left: 90%;
    top: 20px;
}
</style>